package com.prs.crm.service.flow;

import java.util.Collection;
import java.util.List;

import org.courser.ui.PaginationSupport;

import com.prs.crm.domain.FlowEntity;
import com.prs.crm.domain.flow.WorkFlowProcess;
import com.prs.crm.domain.flow.WorkFlowProcessNode;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.service.BaseService;

public interface WorkFlowProcessService extends BaseService<WorkFlowProcess>{
	
	PaginationSupport listFlowNodes(PaginationSupport page,WorkFlowProcess process,Integer[] status);

	Collection<WorkFlowProcessNode> getNodeByStatus(WorkFlowProcess process,Integer status);
	
	Collection<WorkFlowProcessNode> getNodeByNodeType(WorkFlowProcess process,Integer nodeType);
	
	Collection<WorkFlowProcessNode> getNextProcessNodes(WorkFlowProcessNode node);
	
	void saveProcessNode(WorkFlowProcessNode node);
	
	@SuppressWarnings("unchecked")
	FlowEntity findProcessEntity(WorkFlowProcess process,Class cls);
	
	void saveProcessEntity(FlowEntity entity);
	
	int countProcessNodes(WorkFlowProcess process,Integer status,Integer result);
	
	/**
	 * 更新执行流程结点的状态和结果信息
	 * @param process
	 * @param status
	 * @param result
	 */
	int  updateProcessNode(final WorkFlowProcess process,final Integer status,final Integer result);
	
	
	/**
	 * 列出审批已经完成的节点
	 * @param cls
	 * @param page
	 * @return
	 */
	Collection<WorkFlowProcessNode> pageHistoryFlowNode(FlowEntity entity);
	
	
	/**
	 * 分页查询流程结点
	 * @param cls
	 * @param page
	 * @param person
	 * @param status
	 * @return
	 */
	PaginationSupport pageQueryFlowNode(Class<?> cls,PaginationSupport page,Person person,Integer[] status);
	
	
	WorkFlowProcess   getWorkFlowProcess(java.io.Serializable id);


	List<WorkFlowProcessNode> getWorkFlowProcessNode(WorkFlowProcess flowProcess);
	
	
	void saveOrUpdate(WorkFlowProcess flowProcess);
	
	void saveOrUpdateWorkFlowProcessNode(WorkFlowProcessNode workFlowProcessNode);
}
